package com.xhj.xmly.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.xhj.xmly.R;
import com.xhj.xmly.bean.Classily;

import java.util.List;

/**
 * Created by Administrator on 2016/12/5.
 */

public class ClassilyAdapter extends RecyclerView.Adapter<ClassilyAdapter.ViewHolder>  {
private List<Classily.ListBean> datas;
    private Context context;

    public ClassilyAdapter(List<Classily.ListBean> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.classly_frag_item,parent,false);
        ViewHolder holder=new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

             holder.title.setText(datas.get(position).getTitle());
             Picasso.with(context).load(datas.get(position).getCoverPath()).into(holder.icon);

    }

    @Override
    public int getItemCount() {
        return datas.size();
    }



    public static class ViewHolder extends RecyclerView.ViewHolder{
      private ImageView icon;
      private  TextView title;
        ImageView head;

        public ViewHolder(View itemView) {
            super(itemView);
            icon=(ImageView)itemView.findViewById(R.id.classify_item_icon);
            title=(TextView)itemView.findViewById(R.id.classify_item_title);
        }
    }
}
